import com.b2c.common.utils.PageResult;
import com.mr.GoodPageApplication;
import com.mr.client.GoodsClient;
import com.mr.service.FileStaticService;
import com.mr.service.SpuBo;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;

@RunWith(SpringRunner.class)
@SpringBootTest(classes = { GoodPageApplication.class})
public class CartePageText {
    @Autowired
    private GoodsClient goodsClient;

    @Autowired
    private FileStaticService fileService;

    @Test
    public void createPage() {
        //查询spu分页数据
        int page=0;
        boolean load = true;
        while (load) {
            PageResult<SpuBo> spuPage = goodsClient.querySpuByPage(page++, 10, true, "");

            if(spuPage.getItems().size()==0){
                load=false;
            }

            spuPage.getItems().forEach(spuBo -> {
                try {
                    //循环创建静态文件
                    fileService.createStaticHtml(spuBo.getId());
                } catch (Exception e) {
                    e.printStackTrace();
                }
            });
        }
    }
}